#ifndef CELLSOLVER
#define CELLSOLVER

#include "cellmodel.h"

#include <queue>

using namespace std;	

/** 
 * class CellSolver
 * helps cell compute all things necesarry 
 * for its lifecycle
 * it communicates with other modules
 * cell2cell module and environment module
 * and provides necesarry external data for cells
 *
 * it provides computation of differential equations
 * for cell
 *
 * cell sends demands on cellsolver
 * cellsolve sends back information about what to do next
 * it should be possible to have more cellsolvers
 * for possible parallel computation
 *
 */
class CellSolver {

private:

	/** queue for incoming messages */
	queue <Message> messages;



	//------------------------------------------------
	// Processing only one message
	//------------------------------------------------

	/** process one external force message */
	void processExternalForce( Message message );

	/** process one new particle position message */
	void processNewParticlePosition( Message message );



	//------------------------------------------------
	// Process messages of one type
	//------------------------------------------------

	/** process all external force messages */
	void processAllExternalForce();

	/** process all new particle position messages */
	void processAllNewParticlePosition();




public:

	/** cellsolver accepts message from cell 
	 * @param message message
	 * @param from pointer to cell who sent message
	 */
	void receive( Message * message );

	/** send to cell model 
	 * @param to cell to send message to
	 * @param message message 
	 */
	void send( CellModel * to, Message * message );

	/**********************************************
	 *   methodts for processing all messages
	 *   processGrow()
	 *	 processForces()
	 *   ...
	 *********************************************/
	
	/**
	 * Cell solver provides method life cycle
	 * it gets from general model representing simulation
	 * message to handle lifecycles of cells
	 * method lifecycle is divided into many functional phases
	 * the information about how cell lifecycle goes is held here
	 * in every phase specific need of all cells is handled
	 * e.g. one phase is computation of all external forces
	 * another is computation of new cell positions
	 *
	 * @param step step is double from open interval (0,1) 
	 * 
	 */
	void lifecycle( double step );


};




#endif // CELLSOLVER